package com.imooc.user.repository;

import com.imooc.user.mapping.UserMapping;
import com.imooc.user.provider.model.UserCenterUserVo;
import com.imooc.user.provider.service.UserCenterUserService;
import com.imooc.user.repository.entity.TUserCenterUser;
import com.imooc.user.repository.service.ITUserCenterUserService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

/**
 * @Author Tim
 * @Description:
 * @Version 1.0
 */
@DubboService
public class UserRepository implements UserCenterUserService {

    private final ITUserCenterUserService userService;

    private final UserMapping userMapping;

    public UserRepository(ITUserCenterUserService userService, UserMapping userMapping) {
        this.userService = userService;
        this.userMapping = userMapping;
    }

    public List<UserCenterUserVo> getUsersByGroupId(String groupId){
        List<TUserCenterUser> users = userService.getUsersByGroupId(groupId);
        return userMapping.convert(users);
    }

    @Override
    public List<UserCenterUserVo> getUsersByGroupId(List<String> groupIds) {
        List<TUserCenterUser> list = userService.getUsersByGroupIds(groupIds);
        return userMapping.convert(list);
    }
}
